﻿<!DOCTYPE html>
<html style="height: 100%">
<head>
    <meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
    <div id="container" style="height: 100%; background-color:black;"></div>
    <script type="text/javascript" src="assets/jquery.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM"></script>
    <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js"></script>
    <script type="text/javascript">
        var dom = document.getElementById("container");
        var myChart = echarts.init(dom);
        var app = {};
        option = null;
        app.title = '力引导布局';

        myChart.showLoading();
        $.get('data/data-force-airline.gexf.xml', function (xml) {
            myChart.hideLoading();

            var graph = echarts.dataTool.gexf.parse(xml);
            var categories = [{
                name: '区域',
                itemStyle: {
                    normal: {
                        color: 'rgb(255, 22, 22)'
                    }
                },
                label: {
                    normal: {
                        textStyle: {
                            color: '#FFF'
                        }
                    }
                }
            }, {
                name: '公司',
                itemStyle: {
                    normal: {
                        color: 'rgb(22, 22, 255)'
                    }
                },
                label: {
                    normal: {
                        textStyle: {
                            color: '#FFF'
                        }
                    }
                }
            }, {
                name: '客户',
                itemStyle: {
                    normal: {
                        color: 'rgb(255, 255, 22)'
                    }
                },
                label: {
                    normal: {
                        textStyle: {
                            color: '#FFF'
                        }
                    }
                }
            }];
            graph.nodes.forEach(function (node) {
                node.itemStyle = null;
                node.symbolSize = 10;
                node.value = node.symbolSize;
                node.category = node.attributes.modularity_class;
                // Use random x, y
                node.x = node.y = null;
                node.draggable = false;
            });
            option = {
                title: {
                    text: '空运航空货代',
                    subtext: 'Default layout',
                    top: 'bottom',
                    left: 'right'
                },
                backgroundColor:'#000',
                tooltip: {},
                legend: [{
                    // selectedMode: 'single',
                    data: categories.map(function (a) {
                        return a.name;
                    }),
                    textStyle: {
                        color: '#FFF'
                    }
                }],
                animation: false,
                series: [
                    {
                        name: '空运航空货代',
                        type: 'graph',
                        layout: 'force',
                        data: graph.nodes,
                        links: graph.links,
                        categories: categories,
                        roam: true,
                        //width: 800,
                        //height: 800,
                        label: {
                            normal: {
                                position: 'right'
                            }
                        },
                        force: {
                            repulsion: 30
                        }
                    }
                ]
            };

            myChart.setOption(option);
        }, 'xml');;
        if (option && typeof option === "object") {
            myChart.setOption(option, true);
        }
    </script>
</body>
</html>